package futbol.tacticas.concursantes.FCAlexB;

public class Triangulo {

	//Propiedades
	private double[] cA=new double[2];
	private double[] cB=new double[2];
	private double[] cC=new double[2];
	private double A;
	private double B;
	private double C;
	private double area;
	private double perimetro;
	
	//Constructor
	public Triangulo(double aX, double aY, double bX, double bY,double cX,double cY){
		this.cA[0]=aX;
		this.cA[1]=aY;
		this.cB[0]=bX;
		this.cB[1]=bY;
		this.cC[0]=cX;
		this.cC[1]=cY;
		this.A=Math.sqrt((Math.pow((cX-bX), 2))+(Math.pow((cY-bY), 2)));
		this.B=Math.sqrt((Math.pow((cX-aX), 2))+(Math.pow((cY-aY), 2)));
		this.C=Math.sqrt((Math.pow((aX-bX), 2))+(Math.pow((aY-bY), 2)));
		this.perimetro=(Math.sqrt((Math.pow((cX-bX), 2))+(Math.pow((cY-bY), 2))))+(Math.sqrt((Math.pow((cX-aX), 2))+(Math.pow((cY-aY), 2))))+(Math.sqrt((Math.pow((aX-bX), 2))+(Math.pow((aY-bY), 2))));
		this.area=Math.sqrt((perimetro/2)*((perimetro/2)-(Math.sqrt((Math.pow((cX-bX), 2))+(Math.pow((cY-bY), 2)))))*((perimetro/2)-(Math.sqrt((Math.pow((cX-aX), 2))+(Math.pow((cY-aY), 2)))))*((perimetro/2)-(Math.sqrt((Math.pow((aX-bX), 2))+(Math.pow((aY-bY), 2))))));
	}
	
	//Getters y setters
	public double[] getCA() {
		return cA;
	}
	public void setCA(double[] ca) {
		cA = ca;
	}
	public double[] getCB() {
		return cB;
	}
	public void setCB(double[] cb) {
		cB = cb;
	}
	public double[] getCC() {
		return cC;
	}
	public void setCC(double[] cc) {
		cC = cc;
	}
	public double getA(){
		return A;
	}
	public double getB(){
		return B;
	}
	public double getC(){
		return C;
	}
	
	public double getArea() {
		return area;
	}
	
	public double getPerimetro() {
		return perimetro;
	}

		
	//Metodo para saber si un punto (x,y) est en el tringulo
	public boolean isInTriangulo(double x, double y){
			Triangulo parteA= new Triangulo(this.getCB()[0], this.getCB()[1], this.getCC()[0], this.getCC()[1], x, y);
			Triangulo parteB= new Triangulo(this.getCA()[0], this.getCA()[1], this.getCC()[0], this.getCC()[1], x, y);
			Triangulo parteC= new Triangulo(this.getCB()[0], this.getCB()[1], this.getCA()[0], this.getCA()[1], x, y);
			if ((parteA.getArea()+parteB.getArea()+parteC.getArea())==this.getArea()){
				return true;
			}
		return false;
	}

}
